package com.jianbing.zuixia.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.zuixia.domain.ZuixiaPersonalAnswerRoute;
import com.jianbing.zuixia.service.IZuixiaPersonalAnswerRouteService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 个人答题路线，记录用户每天的答题路线Controller
 * 
 * @author windbless
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/zuixia/person_route")
public class ZuixiaPersonalAnswerRouteController extends BaseController
{
    @Autowired
    private IZuixiaPersonalAnswerRouteService zuixiaPersonalAnswerRouteService;

    /**
     * 查询个人答题路线，记录用户每天的答题路线列表
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZuixiaPersonalAnswerRoute zuixiaPersonalAnswerRoute)
    {
        startPage();
        List<ZuixiaPersonalAnswerRoute> list = zuixiaPersonalAnswerRouteService.selectZuixiaPersonalAnswerRouteList(zuixiaPersonalAnswerRoute);
        return getDataTable(list);
    }

    /**
     * 导出个人答题路线，记录用户每天的答题路线列表
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:export')")
    @Log(title = "个人答题路线，记录用户每天的答题路线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZuixiaPersonalAnswerRoute zuixiaPersonalAnswerRoute)
    {
        List<ZuixiaPersonalAnswerRoute> list = zuixiaPersonalAnswerRouteService.selectZuixiaPersonalAnswerRouteList(zuixiaPersonalAnswerRoute);
        ExcelUtil<ZuixiaPersonalAnswerRoute> util = new ExcelUtil<ZuixiaPersonalAnswerRoute>(ZuixiaPersonalAnswerRoute.class);
        util.exportExcel(response, list, "个人答题路线，记录用户每天的答题路线数据");
    }

    /**
     * 获取个人答题路线，记录用户每天的答题路线详细信息
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:query')")
    @GetMapping(value = "/{routeId}")
    public AjaxResult getInfo(@PathVariable("routeId") Long routeId)
    {
        return success(zuixiaPersonalAnswerRouteService.selectZuixiaPersonalAnswerRouteByRouteId(routeId));
    }

    /**
     * 新增个人答题路线，记录用户每天的答题路线
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:add')")
    @Log(title = "个人答题路线，记录用户每天的答题路线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZuixiaPersonalAnswerRoute zuixiaPersonalAnswerRoute)
    {
        return toAjax(zuixiaPersonalAnswerRouteService.insertZuixiaPersonalAnswerRoute(zuixiaPersonalAnswerRoute));
    }

    /**
     * 修改个人答题路线，记录用户每天的答题路线
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:edit')")
    @Log(title = "个人答题路线，记录用户每天的答题路线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZuixiaPersonalAnswerRoute zuixiaPersonalAnswerRoute)
    {
        return toAjax(zuixiaPersonalAnswerRouteService.updateZuixiaPersonalAnswerRoute(zuixiaPersonalAnswerRoute));
    }

    /**
     * 删除个人答题路线，记录用户每天的答题路线
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:person_route:remove')")
    @Log(title = "个人答题路线，记录用户每天的答题路线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeIds}")
    public AjaxResult remove(@PathVariable Long[] routeIds)
    {
        return toAjax(zuixiaPersonalAnswerRouteService.deleteZuixiaPersonalAnswerRouteByRouteIds(routeIds));
    }
}
